/*
 * EquilibriumConstant.cpp
 *
 *  Created on: 31 Jul 2011
 *      Author: Allan
 */

#include "EquilibriumConstant.h"

// C++ includes
#include <cmath>

EquilibriumConstant::EquilibriumConstant() :
logKi(1, 0.0), Ti(1, 25.0), li(Ti, logKi), knownfunction(false)
{}

EquilibriumConstant::EquilibriumConstant(double logK) :
logKi(1, logK), Ti(1, 25.0), li(Ti, logKi), knownfunction(false)
{}

EquilibriumConstant::EquilibriumConstant(double logK, double T) :
logKi(1, logK), Ti(1, T), li(Ti, logKi), knownfunction(false)
{}

EquilibriumConstant::EquilibriumConstant(const vector<double>& logKi, const vector<double>& Ti) :
logKi(logKi), Ti(Ti), li(Ti, logKi, 2), knownfunction(false)
{}

EquilibriumConstant::EquilibriumConstant(const Function& K)
{
	this->K = K;
	
	knownfunction = true;
}

void EquilibriumConstant::GetData(vector<double>& logKi, vector<double>& Ti) const
{
	logKi = this->logKi;
	Ti    = this->Ti;
}

const EquilibriumConstant::Function EquilibriumConstant::GetFunction() const
{
	return K;
}

const double EquilibriumConstant::operator()(double T, double P) const
{
	if(knownfunction)
		return K(T, P);
	else
		return std::pow(10.0, li(T));
}
